package com.byxy.ssm.demo.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.byxy.ssm.demo.entity.Tip;

public interface TipDao {
	@Results(id="usermap",value=
			{
				@Result(column="tip_id",property="tipId",id=true),
				@Result(column="user_id",property="userId"),
				@Result(column="tab_id",property="tabId"),
				@Result(column="tip_title",property="tipTitle"),
				@Result(column="tip_content",property="tipContent"),
				@Result(column="tip_publishTime",property="tipPublishTime"),
				@Result(column="tip_modifyTime",property="tipModifyTime"),
				@Result(column="tip_click",property="tipClick"),
				@Result(column="tip_isDeleted",property="tipIsDeleted"),// 没有CTRL+C CTRL+V
				@Result(column="tip_isKnot",property="tipIsKnot"),
				@Result(column="tip_replies",property="tipReplies")
				}
			)
	
	@Select("select * from tip")
	List<Tip> find();
	
	@Insert("insert into tip(user_id,tab_id,tip_title,tip_content,tip_publishTime,tip_modifyTime,tip_click,tip_isDeleted,tip_isKnot,tip_replies) values"
			+ "(#{userId},#{tabId},#{tipTitle},#{tipContent},#{tipPublishTime},#{tipModifyTime},#{tipClick},#{tipIsDeleted},#{tipIsKnot},#{tipReplies})")
	void add(Tip tip);
	
	@ResultMap("usermap")
	@Select("select * from tip where tip_id=#{tipId}")
	Tip finById(Integer tipId);

	




	

	
	
	
	

}
